# 列表推导式
lst = [x for x in range(20) if x%2==1 ]
print(type(lst),lst)


# 生成器表达式,上面的列表推导式把 方括号改为 括号
g = (x for x in range(20) if x%2==1 )
print(type(g),g)
# for 循环来访问生成器
# for x in g:
#     print(x)

#生成器直接转list
l = list(g)
print(l)


#字典推导式
scores ={"jack":98,"tiger":88,"rose":60,"mike":44,"jane":50}
flunk = {k : v for k,v in scores.items() if v < 60 }
print(flunk)

#集合推导式
names = {k for k,v in scores.items() if v < 60 }
print(type(names),names)